export default {
    state:()=>({
        name:'yuanxi',
        ceshi:'this is '
    }),
    getters:{
        getFullName(state){
            return state.ceshi + state.name;
        },
        getFullName2(state,getters){
            return getters.getFullName + ' getFullName2的方法';
        },
        //获取父类的rootState
        getFullName3(state,getters, rootState){
            return getters.getFullName + rootState.num;
        },
    },
    mutations:{
        setName(state,payload){
            console.log(payload);
            state.name = payload;
        },
        setName2(state,payload){
            console.log(payload);
            state.name = payload;
        }
    },
    actions:{
        test1({state,commit,getters},aaa){
            setTimeout(()=>{
                // 使用mutations来改变changeCnum是mutations的方法
                console.log(aaa);
                commit('setName2',aaa);
            },3000);
        },
        test2(context,xxx){
            console.log(context);
            console.log(xxx);
            setTimeout(()=>{
                context.commit('setName2',xxx);
            },3000);
        },
    }
}